import { writable } from 'svelte/store';
function createToast() {
  const { subscribe, set, update } = writable({ message: '', visible: false });
 
  function show(message, duration = 3000) {
    set({ message, visible: true });
    setTimeout(() => {
      update(current => ({ ...current, visible: false }));
    }, duration);
  }
 
  return {
    subscribe,
    show, // 公开show方法供外部调用
  };
}
 
export const toast = createToast(); // 创建并导出toast服务实例